import {defineConfig} from "vite";
import {resolve} from "path";
import vue from "@vitejs/plugin-vue";


const host = process.env.TAURI_DEV_HOST;


// https://vite.dev/config/
export default defineConfig({
    plugins: [vue()],
    // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
    clearScreen: false,
    server: {
        port: 1420,
        strictPort: true,
        host: host || false,
        hmr: host
            ? {
                protocol: "ws",
                host,
                port: 1421,
            }
            : undefined,
        watch: {
            ignored: ["**/src-tauri/**"],
        },
    },
    build: {
        target: "esnext", // 添加这一行以支持 top-level await
        rollupOptions: {
            input: {
                main: resolve(__dirname, 'index.html'),
                settings: resolve(__dirname, 'settings.html')
            }
        }
    },
    resolve: {
        alias: {
            "@": resolve(__dirname, "./src"),
        },
    },
    css: {
        preprocessorOptions: {
            scss: {
                // additionalData: '@use "@/styles/variable.scss" as *;',
            },
        },
    },
});
